<?php
$query = "SELECT * FROM nm_guildes WHERE nmg_ok='1' ORDER by nmg_nom ASC;";
$result = mysql_query($query);
echo '<table class="noir">
	<tr><th>Guilde</th><th>Chef</th><th>Guerre</th><th>Membres</th></tr>';

while($guilde = mysql_fetch_object($result)){
	$r1 = mysql_query("SELECT nmr_nom FROM nm_royaume WHERE nmr_id='".$guilde->nmg_chef."';");
	
	if ( mysql_num_rows($r1) == 0 ){
		$chef = "<b><font color=\"red\">Le chef n'existe plus!!</font></b>";
	}else{
		$chef = stripslashes(mysql_result($r1, 0, "nmr_nom"));
	}
	
	if ( $guilde->nmg_guerre != 0 ){
		$guerre = "<b><font color=\"blue\">En guerre contre ".$guilde->nmg_guerre." ".icon("guildeInfos", $guilde->nmg_guerre)."</font></b>";
	}else{
		$guerre = "Guilde en temps de paix.";
	}
	
	
	$r2 = mysql_query("SELECT nmr_id FROM nm_royaume WHERE nmr_guilde = '".$guilde->nmg_id."' ORDER by nmr_nom ASC;");
	$membres = mysql_num_rows($r2);
	
	if ( $membres < 3 ) $membres = "<font color=\"red\">$membres</font>";
	
	echo '<tr>
		<td>'.icon("guildeDelete",$guilde->nmg_id).icon("guildeInfos",$guilde->nmg_id).' '.stripslashes($guilde->nmg_nom).' ('.$guilde->nmg_id.')</td>
		<td>'.icon("infos", $guilde->nmg_chef).' '.$chef.'</td>
		<td>'.$guerre.'</td>
		<td class="texteCentre">'.$membres.'</td></tr>';
}

echo "</table>";

?>